package com.tbit.uqbike.client.service.impl;

import com.tbit.uqbike.client.dao.core.RechargeDao;
import com.tbit.uqbike.client.pojo.Recharge;
import com.tbit.uqbike.client.service.RechargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("rechargeService")
public class RechargeServiceImpl implements RechargeService {
    @Autowired
    private RechargeDao rechargeDao;

    @Override
    public void insert(Recharge recharge) {
        rechargeDao.insert(recharge);
    }

    @Override
    public List<Recharge> getByIdAndState(Integer userId, Integer type, Integer state) {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        map.put("type", type);
        map.put("state", state);
        return rechargeDao.getByIdAndState(map);
    }

    @Override
    public Recharge getByOrderNO(String orderNO) {
        return rechargeDao.getByOrderNO(orderNO);
    }

    @Override
    public void update(Recharge recharge) {
        rechargeDao.update(recharge);
    }

    @Override
    public Recharge getByWxzzfNotPay(Integer userId, Integer type) {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        map.put("type", type);
        return rechargeDao.getByWxzzfNotPay(map);
    }

    @Override
    public void editWizffPay(Recharge recharge) {
        rechargeDao.editWizffPay(recharge);
    }

    @Override
    public List<Recharge> getByUserIdAndType(Integer userId, String startTime) {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        map.put("rechargeTime", startTime);
        return rechargeDao.getByUserIdAndType(map);
    }

    @Override
    public Recharge getUserNotPayOrder(Integer userId) {
        return rechargeDao.getUserNotPayOrder(userId);
    }

    @Override
    public void editType(Recharge recharge) {
        rechargeDao.editType(recharge);
    }

    @Override
    public Recharge getExemptByType(Integer userId, Integer rechargeType) {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        map.put("rechargeType", rechargeType);
        return rechargeDao.getExemptByType(map);
    }


}